<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<script src="vue.js" type="text/javascript" charset="utf-8"></script>
	</head>

	<body>
		<!--
			对于数据属性，vue机制先在data里面查找，如果没有再从计算属性computed中查找
		-->
		<div id="app">{{fullName}}</div>
		<script type="text/javascript">
			var vm = new Vue({
				el: "#app",
				data: {
					firstName: "Dell",
					lastName: "Lee",
					age: 23
				},
				computed: {
					//					fullName: function() {
					//						console.log("计算了一次");
					//						return this.firstName + " " + this.lastName
					//					},
					fullName: {
						//当获取计算属性值fullName的时候出发其里面的get方法
						get: function() {
							console.log("get");
							return this.firstName + " " + this.lastName;
						},
						//当设置属性值fullName的时候出发其里面的set方法，传入的参数v就是计算属性设置的值
						set: function(v) {
							console.log("set");
							console.log(v);
							var arr = v.split(" ");
							this.firstName = arr[0];
							this.lastName = arr[1];
						}
					}

				}
			})
		</script>

	</body>

</html>